# -*- coding: utf-8 -*-

from django.contrib import admin
from onecall.main.models import *

class ClinicPhoneInline(admin.TabularInline):
    model = ClinicPhone

class ClinicAdmin(admin.ModelAdmin):
    list_display = ['legal_name', 'region','email']
    inlines = [ClinicPhoneInline]
    list_filter = ['region']
    
    raw_id_fields = ('fact_address','legal_address',)
    
    list_display = ('legal_name', 'commercial_name', 'short_name', 'region')
    search_fields = ('legal_name', 'commercial_name', 'short_name',)
    fieldsets = (
        (None, {
            'fields': ['legal_name', 'commercial_name', 'short_name', 'region']
        }),
        (u'Фактический адрес', {
            'classes': ('collapse',),
            'fields': ['fact_address', 'fact_address_house_number','fact_address_house_letter']
        }),
        (u'Юридический адрес', {
            'classes': ('collapse',),
            'fields': ['legal_address_postindex', 'legal_address','legal_address_house_number','legal_address_house_letter']
        }),
        (u'Контактная информация', {
            'classes': ('collapse',),
            'fields': ['fax', 'email','path','timetable',]
        }),        
    )

admin.site.register(Clinic, ClinicAdmin)

class ClinicPhoneAdmin(admin.ModelAdmin):
    pass
        
admin.site.register(ClinicPhone, ClinicPhoneAdmin)

class SpecialistAdmin(admin.ModelAdmin):
    search_fields = ('lastname','firstname','fathername')
    list_filter = ('clinic', 'academic_degree','category')
    list_filter = ['lastname']

admin.site.register(Specialist, SpecialistAdmin)

class ServiceAdmin(admin.ModelAdmin):
    search_fields = ('name',)
admin.site.register(Service, ServiceAdmin)

class RequestAdmin(admin.ModelAdmin):
    pass
#    list_display = ('id', 'rec_create_date', 'rec_create_time')
    #list_per_page = 20
    #radio_fields = {
        #"answer": admin.VERTICAL,
#        "reason": admin.VERTICAL,
        #}
#     ordering = ('-rec_create_date',)

admin.site.register(Request, RequestAdmin)

class TariffAdmin(admin.ModelAdmin):
    pass
admin.site.register(Tariff, TariffAdmin)

class ContractAdmin(admin.ModelAdmin):
    # date_hierarchy = 'rec_create_date'
    list_filter = ('status', )

admin.site.register(Contract, ContractAdmin)

class BillAdmin(admin.ModelAdmin):
    pass
admin.site.register(Bill, BillAdmin)

class DirectionAdmin(admin.ModelAdmin):
    pass
admin.site.register(Direction, DirectionAdmin)

class TimetableAdmin(admin.ModelAdmin):
    fieldsets = (
        ('Понедельник', {            
            'fields': (('monday_begin', 'monday_end'),)
        }),
        ('Вторник', {
            'fields': (('tuesday_begin', 'tuesday_end'),)
        }),
        ('Среда', {
            'fields': (('wednesday_begin', 'wednesday_end'),)
        }),
        ('Четверг', {
            'fields': (('thursday_begin', 'thursday_end'),)
        }),
        ('Пятница', {
            'fields': (('friday_begin', 'friday_end'),)
        }),
        ('Суббота', {
            'fields': (('saturday_begin', 'saturday_end'),)
        }),
        ('Воскресенье', {
            'fields': (('sunday_begin', 'sunday_end'),)
        }),
    )

admin.site.register(Timetable, TimetableAdmin)
